# -*- coding: utf-8 -*-
"""
Created on Sat Dec  5 10:15:20 2020
send_keys
Keys.CONTROL + v 
Keys.DOWN
driver.find_element_by_tag_name('body')
@author: andrew
"""
import time
from selenium import webdriver 
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
# create webdriver object 
driver = webdriver.Chrome('./diver/chromedriver')
driver.get("http://www.python.org")
time.sleep(2)
# <input id="id-search-field" name="q" type="search" role="textbox" class="search-field" placeholder="Search" value="Pycon " tabindex="1">
# get element  
# element = driver.find_element_by_name("q") 
element = driver.find_element(By.CLASS_NAME,"search-field")
# # send keys  
element.clear()
element.send_keys("Pycon ")
element.send_keys((Keys.COMMAND, 'v'))
time.sleep(2)
element.send_keys((Keys.COMMAND, 'a'))
time.sleep(2)
element.send_keys(Keys.RETURN)
time.sleep(1)
# 找到标签Body
element = driver.find_element_by_tag_name('body')
for i in range(200):
    element.send_keys(Keys.PAGE_DOWN)
    # time.sleep(1)
time.sleep(5)
driver.quit()

